Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Memory

Previous | Chapter Top | Chapter Contents | Next |

Accessing Heap Zones

The majority of applications, which allocate memory in their application heap zone only, do not need to use any of the routines in this section. The few applications that do allocate memory in zones other than the application heap zone can use the GetZone function and the SetZone procedure to get and set the current zone, the ApplicationZone and SystemZone functions to obtain pointers to the application and system zones, and the HandleZone and PtrZone functions to find the zones in which relocatable and nonrelocatable blocks lie.

GetZone

To find which zone is current, use the GetZone function.

FUNCTION GetZone: THz;

DESCRIPTION

The GetZone function returns a pointer to the current heap zone.

ASSEMBLY-LANGUAGE INFORMATION

The registers on exit for GetZone are

Registers on exit

A0

Pointer to current heap zone

D0

Result code

The global variable TheZone contains a pointer to the current heap zone.

RESULT CODES

noErr

0

No error

SetZone

To change the current heap zone, you can use the SetZone procedure.

PROCEDURE SetZone (hz: THz);
hz
A pointer to the heap zone to make current.

DESCRIPTION

The SetZone procedure makes the zone to which hz points the current heap zone. Often, you use the SetZone procedure in conjunction with one of the ApplicationZone , SystemZone , HandleZone , and PtrZone functions. For example, the code SetZone(SystemZone) makes the system heap zone current.

ASSEMBLY-LANGUAGE INFORMATION

The registers on entry and exit for SetZone are

Registers on entry

A0

Pointer to new current heap zone

Registers on exit

D0

Result code

RESULT CODES

noErr

0

No error

ApplicationZone

To obtain a pointer to the application heap zone, you can use the ApplicationZone function.

FUNCTION ApplicationZone: THz;

DESCRIPTION

The ApplicationZone function returns a pointer to the original application heap zone.

ASSEMBLY-LANGUAGE INFORMATION

The global variable ApplZone contains a pointer to the original application heap zone.

SystemZone

To obtain a pointer to the system heap zone, you can use the SystemZone function.

FUNCTION SystemZone: THz;

DESCRIPTION

The SystemZone function returns a pointer to the system heap zone.

ASSEMBLY-LANGUAGE INFORMATION

The global variable SysZone contains a pointer to the system heap zone.

HandleZone

If you need to know which heap zone contains a particular relocatable block, you can use the HandleZone function.

FUNCTION HandleZone (h: Handle): THz;
h
A handle to a relocatable block.

DESCRIPTION

The HandleZone function returns a pointer to the heap zone containing the relocatable block whose handle is h . In case of an error, the result returned by HandleZone is undefined and should be ignored.

If the handle h is empty (that is, if it points to a NIL master pointer), HandleZone returns a pointer to the heap zone that contains the master pointer.<36pt>

ASSEMBLY-LANGUAGE INFORMATION

The registers on entry and exit for HandleZone are

Registers on entry

A0

Handle whose zone is to be found

Registers on exit

A0

Pointer to handle's heap zone

D0

Result code

RESULT CODES

noErr

0

No error

memWZErr

-111

Attempt to operate on a free block

PtrZone

If you have allocated a nonrelocatable block and need to know in which zone it lies, you can use the PtrZone function.

FUNCTION PtrZone (p: Ptr): THz;
p
A pointer to a nonrelocatable block.

DESCRIPTION

The PtrZone function returns a pointer to the heap zone containing the nonrelocatable block pointed to by p .

In case of an error, the result returned by PtrZone is undefined and should be ignored.

ASSEMBLY-LANGUAGE INFORMATION

The registers on entry and exit for PtrZone are

Registers on entry

A0

Pointer whose zone is to be found

Registers on exit

A0

Pointer to heap zone of nonrelocatable block

D0

Result code

RESULT CODES

noErr

0

No error

memWZErr

-111

Attempt to operate on a free block


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next